package com.joshua.netdemo.RetrofitDemo;

import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

import com.joshua.netdemo.R;
import com.joshua.netdemo.RetrofitDemo.model.GitHubModel;
import com.joshua.netdemo.RetrofitDemo.vm.MainViewModel;
import com.joshua.netdemo.databinding.AtyRetrofitBinding;

public class RetrofitAty extends AppCompatActivity {
    private AtyRetrofitBinding binding;
    private MainViewModel viewModel;
    private GitHubModel model;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = DataBindingUtil.setContentView(this, R.layout.aty_retrofit);
        binding.setModel(viewModel = new MainViewModel());
        model = new GitHubModel(viewModel);

        binding.button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                viewModel.setPb(true);
                model.getUser(binding.username.getText().toString());
            }
        });
    }
}
